package com.x.erp.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.erp.dao.IntelligentRobotDao;
import com.x.erp.manage.IntelligentRobotManage;
import com.x.erp.model.IntelligentRobot;
import com.x.erp.rpc.IntelligentRobotRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 大屏智能机器人服务
 */
@Component
@Service(interfaceName = "com.x.erp.rpc.IntelligentRobotRpcService", timeout = 60000)
public class IntelligentRobotService extends BaseService implements IntelligentRobotRpcService {

	@Autowired
	private IntelligentRobotDao intelligentRobotDao;//大屏智能机器人信息DAO

	@Autowired
	private IntelligentRobotManage intelligentRobotManage;//大屏智能机器人信息MANAGE

	/**
	 * 查询大屏智能机器人列表
	 * @param intelligentRobot
	 * @return
	 */
	@Override
	public List<IntelligentRobot> selectIntelligentRobotList(IntelligentRobot intelligentRobot){
		try {
			return intelligentRobotDao.selectIntelligentRobotList(intelligentRobot);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 查询大屏智能机器人数量
	 * @param intelligentRobot
	 * @return
	 */
	@Override
	public int selectIntelligentRobotNum(IntelligentRobot intelligentRobot){
		try {
			return intelligentRobotDao.selectIntelligentRobotNum(intelligentRobot);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 新增大屏智能机器人信息
	 * @param intelligentRobot
	 * @return
	 */
	@Override
	public IntelligentRobot insertIntelligentRobot(IntelligentRobot intelligentRobot){
		try {
			return intelligentRobotManage.insertIntelligentRobot(intelligentRobot);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 修改大屏智能机器人信息
	 * @param intelligentRobot
	 * @return
	 */
	@Override
	public int updateIntelligentRobot(IntelligentRobot intelligentRobot){
		try {
			return intelligentRobotManage.updateIntelligentRobot(intelligentRobot);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	@Override
	public IntelligentRobot selectIntelligentRobot(IntelligentRobot intelligentRobot) {
		try {
			return intelligentRobotDao.selectIntelligentRobot(intelligentRobot);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	@Override
	public int deleteIntelligentRobot(IntelligentRobot intelligentRobot) {
		try {
			return intelligentRobotManage.deleteIntelligentRobot(intelligentRobot);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

}
